import java.awt.Toolkit;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.UIManager;

import org.dyno.visual.swing.layouts.Constraints;
import org.dyno.visual.swing.layouts.GroupLayout;
import org.dyno.visual.swing.layouts.Leading;


//VS4E -- DO NOT REMOVE THIS LINE!
public class RulesFrame extends JFrame {

	private static final long serialVersionUID = 1L;
	private JLabel rulesLabel;
	private JButton changePageTo1Button;
	private JButton changePageTo2Button;
	private JButton changePageTo3Button;
	private JButton changePageTo4Button;

	private static final String PREFERRED_LOOK_AND_FEEL = "javax.swing.plaf.metal.MetalLookAndFeel";
	public RulesFrame() {
		initComponents();
	}

	private void initComponents() {
		setTitle("Monopoly");
		setIconImage(Toolkit.getDefaultToolkit().getImage(getClass().getResource("/images/icon.png")));
		setResizable(false);
		setLayout(new GroupLayout());
		add(changePageTo1Button(), new Constraints(new Leading(225, 10, 10), new Leading(640, 10, 10)));
		add(changePageTo2Button(), new Constraints(new Leading(239, 10, 10), new Leading(640, 10, 10)));
		add(changePageTo3Button(), new Constraints(new Leading(255, 10, 10), new Leading(640, 10, 10)));
		add(changePageTo4Button(), new Constraints(new Leading(270, 10, 10), new Leading(640, 10, 10)));
		add(rulesLabel(), new Constraints(new Leading(0, 12, 12), new Leading(0, 12, 12)));
		setSize(500, 700);
		setDefaultCloseOperation(RulesFrame.HIDE_ON_CLOSE);
		getContentPane().setPreferredSize(getSize());
		pack();
		setLocationRelativeTo(null);
		setVisible(false);
	}

	private JButton changePageTo1Button() {
		if (changePageTo1Button == null) {
			changePageTo1Button = new JButton();
			changePageTo1Button.setIcon(new ImageIcon(getClass().getResource("/images/bullet.png")));
			changePageTo1Button.setBorderPainted(false);
			changePageTo1Button.setOpaque(false);
			changePageTo1Button.setBorder(null);
			changePageTo1Button.setContentAreaFilled(false);
			changePageTo1Button.setRolloverIcon(new ImageIcon(getClass().getResource("/images/bullet_p.png")));
			changePageTo1Button.addMouseListener(new MouseAdapter() {
	
				public void mouseClicked(MouseEvent event) {
					changePageTo1ButtonMouseMouseClicked(event);
				}
			});
		}
		return changePageTo1Button;
	}

	private JButton changePageTo2Button() {
		if (changePageTo2Button == null) {
			changePageTo2Button = new JButton();
			changePageTo2Button.setIcon(new ImageIcon(getClass().getResource("/images/bullet.png")));
			changePageTo2Button.setBorderPainted(false);
			changePageTo2Button.setOpaque(false);
			changePageTo2Button.setBorder(null);
			changePageTo2Button.setContentAreaFilled(false);
			changePageTo2Button.setRolloverIcon(new ImageIcon(getClass().getResource("/images/bullet_p.png")));
			changePageTo2Button.addMouseListener(new MouseAdapter() {
				public void mouseClicked(MouseEvent event) {
					changePageTo2ButtonMouseMouseClicked(event);
				}
			});
		}
		return changePageTo2Button;
	}
	private JButton changePageTo3Button() {
		if (changePageTo3Button == null) {
			changePageTo3Button = new JButton();
			changePageTo3Button.setIcon(new ImageIcon(getClass().getResource("/images/bullet.png")));
			changePageTo3Button.setBorderPainted(false);
			changePageTo3Button.setOpaque(false);
			changePageTo3Button.setBorder(null);
			changePageTo3Button.setContentAreaFilled(false);
			changePageTo3Button.setRolloverIcon(new ImageIcon(getClass().getResource("/images/bullet_p.png")));
			changePageTo3Button.addMouseListener(new MouseAdapter() {
				public void mouseClicked(MouseEvent event) {
					changePageTo3ButtonMouseMouseClicked(event);
				}
			});
		}
		return changePageTo3Button;
	}
	private JButton changePageTo4Button() {
		if (changePageTo4Button == null) {
			changePageTo4Button = new JButton();
			changePageTo4Button.setIcon(new ImageIcon(getClass().getResource("/images/bullet.png")));
			changePageTo4Button.setBorderPainted(false);
			changePageTo4Button.setOpaque(false);
			changePageTo4Button.setBorder(null);
			changePageTo4Button.setContentAreaFilled(false);
			changePageTo4Button.setRolloverIcon(new ImageIcon(getClass().getResource("/images/bullet_p.png")));
			changePageTo4Button.addMouseListener(new MouseAdapter() {
				public void mouseClicked(MouseEvent event) {
					changePageTo4ButtonMouseMouseClicked(event);
				}
			});
		}
		return changePageTo4Button;
	}
	
	private JLabel rulesLabel() {
		if (rulesLabel == null) {
			rulesLabel = new JLabel();
			rulesLabel.setIcon(new ImageIcon(getClass().getResource("/images/rule1.jpg")));
		}
		return rulesLabel;
	}

	@SuppressWarnings("unused")
	private static void installLnF() {
		try {
			String lnfClassname = PREFERRED_LOOK_AND_FEEL;
			if (lnfClassname == null)
				lnfClassname = UIManager.getCrossPlatformLookAndFeelClassName();
			UIManager.setLookAndFeel(lnfClassname);
		} catch (Exception e) {
			System.err.println("Cannot install " + PREFERRED_LOOK_AND_FEEL
					+ " on this platform:" + e.getMessage());
		}
	}

	/**
	 * Main entry of the class.
	 * Note: This class is only created so that you can easily preview the result at runtime.
	 * It is not expected to be managed by the designer.
	 * You can modify it as you like.
	 */
	
	private void changePageTo1ButtonMouseMouseClicked(MouseEvent event) {
		rulesLabel.setIcon(new ImageIcon(getClass().getResource("/images/rule1.jpg")));
	}
	private void changePageTo2ButtonMouseMouseClicked(MouseEvent event) {
		rulesLabel.setIcon(new ImageIcon(getClass().getResource("/images/rule2.jpg")));
	}
	private void changePageTo3ButtonMouseMouseClicked(MouseEvent event) {
		rulesLabel.setIcon(new ImageIcon(getClass().getResource("/images/rule3.jpg")));
	}
	private void changePageTo4ButtonMouseMouseClicked(MouseEvent event) {
		rulesLabel.setIcon(new ImageIcon(getClass().getResource("/images/rule4.jpg")));
	}
}